
{% extends 'student_score/layout.html' %}
{% block content %}

    <form class="layui-form" action="">
    <div class="layui-form-item">
    <label class="layui-form-label">年级</label>
    <div class="layui-input-block">
          <input type="checkbox" name="nianji[yi]" title="一年级">
          <input type="checkbox" name="nianji[er]" title="二年级" checked>
          <input type="checkbox" name="nianji[san]" title="三年级">
         <input type="checkbox" name="nianji[si]" title="四年级">
          <input type="checkbox" name="nianji[wu]" title="五年级" checked>
          <input type="checkbox" name="nianji[liu]" title="六年级">
    </div>
  </div>
     <div class="layui-form-item">
    <label class="layui-form-label">学科</label>
    <div class="layui-input-block">
          <input type="checkbox" name="xueke[yuwen]" title="语文">
          <input type="checkbox" name="xueke[shuxue]" title="数学" checked>
          <input type="checkbox" name="xueke[yingyu]" title="英语">
    </div>
  </div>
    <div class="layui-form-item">
    <div class="layui-input-block">
      <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
      <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
  </div>
    </form>
{% endblock %}

{% block js %}
    <script>
        layui.use('form', function(){
         var form = layui.form;
         //监听提交
         layui.code
          form.on('submit(form)', function(data){
         //获取复选框选中的值
         var groupCheckbox=$("input[name='functional']");
         var functional="";
          for(i=0;i<groupCheckbox.length;i++){
           if(groupCheckbox[i].checked){
            var val =groupCheckbox[i].value;
            if(functional.length>0){
            functional+=","+val;
            }else{
            functional+=val;
            }

           }
          }
          data.field.functional=functional;

         $.post("/role/editOk",data.field,function(res){
         if(res.code=="0"){
         layer.msg(res.data);
         }else{
         layer.msg(res.data);
         }
         })
         return false;
         });
        });
</script>

{% endblock %}